package com.hksj.vcm.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hksj.base.query.DeviceOverviewQuery;
import com.hksj.base.vo.ChartVO;
import com.hksj.common.core.model.Rest;
import com.hksj.vcm.query.*;
import com.hksj.vcm.service.VavRoomService;
import com.hksj.vcm.vo.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

@Api(tags = "vav-房间排/送风&压差接口")
@RestController
@RequestMapping("/api/vav/room")
public class VavRoomController {
    @Autowired
    private VavRoomService vavRoomService;

    @ApiOperation(value = "房间-VAV信息",response = VavRoomVO.class)
    @PostMapping("/pageRoomVav")
    public Rest<IPage<VavRoomVO>> pageRoomVav(@RequestBody VavRoomQuery query){
        Page<VavRoomVO> page = vavRoomService.pageRoomVav(query);
        return Rest.ok(page);
    }

    @ApiOperation(value = "房间-分页查询上报历史记录(压力)",response = RoomPropertyVO.class)
    @PostMapping("/pagePressureRecord")
    public Rest<Page<RoomPropertyVO>> pagePressureRecord(@RequestBody @Validated VavRecordQuery query){
        Page<RoomPropertyVO> page = vavRoomService.pagePressureRecord(query);
        return Rest.ok(page);
    }

    @ApiOperation(value = "房间-分页查询上报历史记录(送/排风)",response = RoomPropertyVO.class)
    @PostMapping("/pageWindRecord")
    public Rest<Page<RoomPropertyVO>> pageWindRecord(@RequestBody @Validated VavRecordQuery query){
        Page<RoomPropertyVO> page = vavRoomService.pageWindRecord(query);
        return Rest.ok(page);
    }

    @ApiOperation(value = "变风柜-分页查询上报历史记录(送/排风)",response = RoomPropertyVO.class)
    @PostMapping("/pageDeviceRecord")
    public Rest<Page<RoomPropertyVO>> pageDeviceRecord(@RequestBody @Validated VavDeviceRecordQuery query){
        Page<RoomPropertyVO> page = vavRoomService.pageDeviceRecord(query);
        return Rest.ok(page);
    }

    @ApiOperation(value = "房间-导出上报历史记录(压力)")
    @PostMapping("/exportPressureRecord")
    public void exportPressureRecord(@RequestBody @Validated VavRecordQuery query, HttpServletResponse response){
        vavRoomService.exportPressureRecord(query,response);
    }

    @ApiOperation(value = "房间-导出上报历史记录(送/排风)")
    @PostMapping("/exportWindRecord")
    public void exportWindRecord(@RequestBody @Validated VavRecordQuery query, HttpServletResponse response){
        vavRoomService.exportWindRecord(query,response);
    }

    @ApiOperation(value = "变风柜-导出上报历史记录(送/排风)")
    @PostMapping("/exportDeviceRecord")
    public void exportDeviceRecord(@RequestBody @Validated VavDeviceRecordQuery query, HttpServletResponse response){
        vavRoomService.exportDeviceRecord(query,response);
    }

    @ApiOperation(value = "房间-查询设备各属性折线图")
    @PostMapping("/listChartData")
    public Rest<List<ChartVO>> listChartData(@RequestBody @Validated VavChartQuery query){
        List<ChartVO> list = vavRoomService.listChartData(query);
        return Rest.ok(list);
    }

    @ApiOperation("大屏-房间概览")
    @PostMapping("/getRoomOverview")
    public Rest<RoomOverviewVO> getRoomOverview(@RequestBody @Validated DeviceOverviewQuery query){
        RoomOverviewVO res = vavRoomService.getRoomOverview(query);
        return Rest.ok(res);
    }

    @ApiOperation("大屏-房间送/排风排名")
    @PostMapping("/listVavRoomRank")
    public Rest<List<VavRoomRankVO>> listVavRoomRank(@RequestBody @Validated VavRoomRankQuery query){
        List<VavRoomRankVO> list = vavRoomService.listVavRoomRank(query);
        return Rest.ok(list);
    }

    @ApiOperation("大屏-变风柜送/排风排名")
    @PostMapping("/listVavDeviceRank")
    public Rest<List<VavDeviceRankVO>> listVavDeviceRank(@RequestBody @Validated VavDeviceRankQuery query){
        List<VavDeviceRankVO> list = vavRoomService.listVavDeviceRank(query);
        return Rest.ok(list);
    }

    @ApiOperation(value = "房间-房间当前属性")
    @PostMapping("/getRoomCurrentProperty/{roomId}")
    public Rest<VavRoomVO> getRoomCurrentProperty(@PathVariable Long roomId){
        VavRoomVO room = vavRoomService.getRoomCurrentProperty(roomId);
        return Rest.ok(room);
    }
}
